import React from "react"
import { createStore, applyMiddleware } from 'redux';
import { Provider } from "react-redux";
import { Card } from 'antd';
import redux from "./reactx04/redux"

import ReactX0401 from "./reactx04/reactx04-01"
import ReactX0402 from "./reactx04/reactx04-02"
const logger = store => next => action => {
    //中间件 可以进行处理数据
    console.log("dispatch", action)
    let result = next(action);
    console.log("next-store", store.getState())
    return result
}
class ReactX04 extends React.Component {
    constructor(props) {
        super(props);
        this.store = createStore(redux, {}, applyMiddleware(logger))  //连接redux
        // this.store = createStore(redux, {number:999}, applyMiddleware(logger))  //连接redux
        //第二个参数 就是state 也可以从ajax发过来

    }
    render() {
        return (
            <Provider store={this.store}>
                <Card title="redux合并" bordered={false}>
                    <ReactX0401 />
                    <ReactX0402 />
                </Card>
            </Provider>
        )
    }
}
export default ReactX04